<?php namespace App\Exceptions;
/**
 * Created by PhpStorm.
 * User: Zeopean
 * Date: 2015/8/5
 * Time: 23:07
 */

use Exception;

/**
 * Class InvestorException        处理 投资人信息填充异常
 * @package App\Exceptions
 */
class InvestorException extends Exception
{
    /**
     * 参数定义
     * userIdExists         表示投资者的user_id存在
     * noOrgId              表示投资机构id不存在
     * noInvestFields       表示投资领域不存在
     * noInvestPhase        表示投资阶段不存在
     * noInvestNumSmall     表示投资的最小金额不存在
     * noInvestNumBig       不是投资的最大金额不存在
     */
    const NouserId          = 0x01;
    const NoOrgId           = 0x02;
    const NoInvestFields    = 0x03;
    const NoInvestPhase     = 0x04;
    const NoInvestNumSmall  = 0x05;
    const NoInvestNumBig    = 0x06;
    const NoInvestLogId     = 0x07;
    const noData            = 0x08;

    public function __construct($code, array $data = [], Exception $previous = null)
    {
        switch ($code) {
            case self::NouserId:
                $message = trans('exception.investor.user_id_exists', ['user_id' => array_get($data, 'user_id')]);
                break;
            case self::NoOrgId:
                $message = trans('exception.investor.no_org_id', ['org_id' => array_get($data, 'org_id')]);
                break;
            case self::NoInvestFields:
                $message = trans('exception.investor.no_invest_fields', ['invest_fields' => array_get($data, 'invest_fields')]);
                break;
            case self::NoInvestPhase:
                $message = trans('exception.investor.no_invest_phase', ['invest_phase' => array_get($data, 'invest_phase')]);
                break;
            case self::NoInvestNumSmall:
                $message = trans('exception.investor.no_invest_num_small' ,['invest_num_small' => array_get($data , 'invest_num_small')]);
                break;
            case self::NoInvestNumBig:
                $message = trans('exception.investor.no_invest_num_big' , ['invest_num_big' => array_get($data ,'invest_num_big')]);
            case self::NoInvestLogId:
                $message = trans('exception.investor.no_invest_log_id' , ['invest_log_id' => array_get($data ,'invest_log_id')]);
                break;
            case self::noData:
                $message = trans('exception.investor.no_data');
                break;
            default:
                $message = trans('general.unknown_exception');
                break;
        }

        parent::__construct($message, $code, $previous);
    }
}